﻿@using System.Linq
@using Kugar.Core.ExtMethod
@using Kugar.UI.Web.AdminLTE
@using Kugar.UI.Web.AdminLTE.Enums
@using Kugar.UI.Web.AdminLTE.Helpers
@using Kugar.UI.Web.AdminLTE.Models
@using Kugar.UI.Web.AdminLTE.PageControls
@using Kugar.UI.Web.AdminLTE.PageControls.Helpers.ButtonExtMethod
@using Kugar.UI.Web.AdminLTE.PageControls.PageForms
@using Microsoft.Extensions.Localization
@model Kugar.UI.Web.AdminLTE.Models.Model_AdminUserAuthorityDetail


@inject AdminLTEUI WebUI

@{
    Layout =WebUI.Option.EmbeddedPageLayout.IfEmptyOrWhileSpace(AdminLTEUI.LayoutPath.DefaultLayoutPath);
}

@*@using (WebUI.Control.ModalWindow().Title("管理员详情").ContentHeight(300).ID("divAdminDetail")
   .AddRightButton(btn => btn.Color(ColorPaletteEnum.primary).Text("保存").Type(ButtonTypeEnum.submit))
   .Render())*@
<style>
    td {
        text-align: left;
    }
</style>
    @using (var frm = WebUI.Control.Form().Post()
        .UpdateElementID("divAdminRoleDetail")
        
        .Render())
    {
        using (frm.AddCustomContainer().LabelWidth(0).Render())
        {
<table class="table table-bordered table-hover table-striped">
    <thead>
        <tr>
            <th style="width: 50px"><input type="checkbox" class="selectall" lay-skin="primary" /></th>
            <th style="min-width: 100px;width:30%">@(WebUI.Localizer?["权限名称"]??"权限名称")</th>
            <th>@(WebUI.Localizer?["权限备注"]??"权限备注")</th>
        </tr>
    

    </thead>
    <tbody>
        @foreach (var group in Model.Groups)
        {
            if (!string.IsNullOrWhiteSpace(group.GroupTitle))
            {
                <tr>
                    <td>
                        <input type="checkbox" value="@group.GroupID" name="AuthorityCode" class="selectall"  lay-skin="primary" @((Model.SelectedAuthorityIDs?.All(y=>y==group.Items.SelectMany(x=>x.AuthorityID))??false) ? "checked" : "") />
                    </td>
                    <td>
                        @group.GroupTitle
                    </td>
                    <td>
                    </td>
                </tr>    
            }
            for (int i = 0; i < group.Items.Length; i++)
            {
                var item = group.Items[i];

                <tr>
                    <td>
                        <input type="checkbox" value="@item.AuthorityID" name="AuthorityCode" lay-skin="primary" @((Model.SelectedAuthorityIDs?.Contains(item.AuthorityID) ?? false) ? "checked" : "") />
                    </td>
                    <td>
                        @if (!string.IsNullOrWhiteSpace(group.GroupTitle))
                        {
                            @:&mdash;&mdash;
                        }
                        @item.Title
                    </td>
                    <td>
                        @item.Description
                    </td>
                </tr>
            }
            foreach (var item in group.Items)
            {
                
            }
        }
    </tbody>
</table>

        }
        
        @(frm.AddButtonList()
              .AddButton(x=>x.Text(WebUI.Localizer?["保存"]?? "保存").Type(ButtonTypeEnum.submit).Color(ColorPaletteEnum.success))
              
              .Render()
              )
    }
